import pygame
import sys



#Iniciar pygame
pygame.init()


# Configurar la ventana
ancho = 500
alto = 400
ventana = pygame.display.set_mode((ancho, alto))
pygame.display.set_caption('The Legend Of Elias')
fondo = pygame.image.load("//home/campus54/eliasproject/img/meta.png")


# Pintar el fondo de la ventana
fondo = pygame.image.load("//home/campus54/eliasproject/img/meta.png")
x = 0
y = 0
ventana.blit(fondo, [x,y])
pygame.display.flip()


# Pintar Personajes


avion = pygame.image.load("//home/campus54/eliasproject/img/avion.png")
x = 160
y = 280
ventana.blit(avion, [x,y])
pygame.display.flip()

avion2 = pygame.image.load("//home/campus54/eliasproject/img/avion_derecha.png")
x = 160
y = 280
ventana.blit(avion2, [x,y])
pygame.display.flip()

avion3 = pygame.image.load("//home/campus54/eliasproject/img/avion_izquierda.png")
x = 160
y = 280
ventana.blit(avion3, [x,y])
pygame.display.flip()

avion4 = pygame.image.load("//home/campus54/eliasproject/img/avion_abajo.png")
x = 160
y = 280
ventana.blit(avion4, [x,y])
pygame.display.flip()

pygame.display.update()

	


# Bucle de eventos
while True:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			pygame.quit()
			sys.exit()
			
# Controles
		if event.type == pygame.KEYDOWN:
			
			if event.key == pygame.K_LEFT:	
				ventana.blit(fondo, [0,0])
				x = x - 5	
				ventana.blit(avion3, [x,y])
				pygame.display.flip()
				pygame.display.update()
			
			if event.key == pygame.K_RIGHT:
				ventana.blit(fondo, [0,0])
				x = x + 5
				ventana.blit(avion2, [x,y])
				pygame.display.flip()
				pygame.display.update()
			
			if event.key == pygame.K_UP:	
				ventana.blit(fondo, [0,0])
				y = y - 5	
				ventana.blit(avion, [x,y])
				pygame.display.flip()
				pygame.display.update()
			
			if event.key == pygame.K_DOWN:
				ventana.blit(fondo, [0,0])
				y = y + 5
				ventana.blit(avion4, [x,y])
				pygame.display.flip()
				pygame.display.update()
